<template>
    <div>
        <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/' }">硕士学位申请系统</el-breadcrumb-item>
            <el-breadcrumb-item>盲审总评</el-breadcrumb-item>
        </el-breadcrumb>
        <el-table :data="students" style="width: 100%">
            <el-table-column prop="studentId" label="学号"></el-table-column>
            <el-table-column prop="name" label="姓名"></el-table-column>
            <el-table-column prop="comment" label="盲审意见"></el-table-column>
            <el-table-column prop="result" label="盲审结果"></el-table-column>
            <el-table-column label="处理">
                <template slot-scope="scope">
                    <el-radio-group v-model="scope.row.isQualified" @change="handleStatusChange(scope.row)">
                        <el-radio label="agree">同意</el-radio>
                        <el-radio label="disagree">不同意</el-radio>
                    </el-radio-group>
                </template>
            </el-table-column>
            <el-table-column>
                <template slot-scope="scope">
                    <el-button @click="handleProcess(scope.row)">确认</el-button>
                </template>
            </el-table-column>
        </el-table>
    </div>
</template>

<script>
import axios from "axios";

export default {
    data() {
        return {
            students: [
                {
                    studentId: '001',
                    name: '张三',
                    comment: '好啊好',
                    result: '通过',
                    isQualified: ''
                },
            ]
        };
    },
    methods: {
        getPageList() {
            // axios({
            //     url: `http://localhost:8888/paper/info/pageList?pageNum=1&pageSize=5`,
            //     method: 'get',
            //     responseType: 'json',
            // }).then(res => {
            //     console.log(res);
            //     const students = res.data.data.records;
            //     this.students = students;
            // }).catch(err => {
            //     console.log(err)
            // })
        },
        handleProcess(student) {
            // 根据学生的状态调用后端接口修改论文状态
            // if (student.isQualified === 'agree') {
            //     this.updatePaperStatus(student.studentId, 'agree');
            // } else if (student.isQualified === 'disagree') {
            //     this.updatePaperStatus(student.studentId, 'disagree');
            // }
        },
        updatePaperStatus(studentId, isQualified) {
            // 调用后端接口来更新学生的论文状态
            // 发起 HTTP 请求，传递学生的 ID 和状态给后端
            // 示例中使用了 axios 库来发送 HTTP 请求，你可以根据自己的实际情况使用相应的库或方法
            // 处理成功响应，并显示修改成功的提示框
            // axios({
            //     url: `http://localhost:8888/paper/info/result/${studentId}`,
            //     method: 'put',
            //     data: {
            //         isQualified: isQualified === 'agree' ? '同意' : '不同意'
            //     }
            // }).then(res => {
            //     console.log(res);
            //     this.$message.success('更新成功');
            // }).catch(err => {
            //     console.log(err);
            //     this.$message.error('出错了！');
            // })
        },
    },
    mounted() {
        // this.getPageList();
    }
};
</script>
